<?php
/**
 * User: zoudingyong <sheyingtg@qq.com>
 * Date: 2018-7-3 15:33
 */

namespace app\job\controller;

use think\Db;
use classes\Flow;
use think\facade\Log;
use think\console\command;
use think\console\Input;
use think\console\Output;
class Task
{

    //触发定时结算
    public function time_settlement()
    {

        try {
            $data = Db::name('community_order_settlement')
                ->where('status=0 AND (unix_timestamp(create_at)+24*3600*3) <= unix_timestamp(now()) ')
                ->select();
            if (!empty($data)) {
                foreach ($data as $one) {
                    Flow::CreateFromSettlement($one);
                }
            }
            Log::record('settlement_ok');
            echo 'ok';

        } catch (\Exception $e) {
            Log::error('settlement_fail');
        }
    }

}
